package com.tx.framework.util;

import org.springframework.util.StringUtils;

/**
 * 
 * @author Administrator
 *
 */
public class StringUtil {

	/**
	 * 判断是否为Int类型
	 * 
	 * @param str
	 * @return
	 */
	public static Boolean isInt(String str) {
		try {
			Integer.parseInt(str);
			return true;
		} catch (Exception ex) {
			return false;
		}
	}
	
	public static Boolean isDecimal(String str) {
		try {
			Float.parseFloat(str);
			return true;
		} catch (Exception ex) {
			return false;
		}
	}

	public static Long null2Zero(Long itg) {
		if (itg == null) {
			return 0l;
		}
		return itg;
	}

	public static String null2Nothing(Object obj) {
		if (obj == null) {
			return "";
		}
		return obj.toString();
	}
	
	public static Boolean isEmpty(Object obj){
		if(StringUtils.isEmpty(obj)){
			return true;
		}
		return false;
	}
	
	public static Boolean isGreateThanZero(Object obj){
		if(!isEmpty(obj) && isInt(obj.toString())){
			if(Integer.parseInt(obj.toString())>0){
				return true;
			}
		}
		return false;
	}
}
